<template>
	<view class="post">
		<!-- 		<view class="post-imgs">
			<image v-for="img in post.imgs"
				:src="`http://127.0.0.1:8090/api/files/${post.collectionId}/${post.id}/${img}`" alt="" />
		</view> -->



		<view class="post-title">
			{{post.title}}
		</view>

		<view v-if="post.belong" class="post-belong">
			所属景区: {{post.expand.belong.title}}
		</view>

		<view v-if="post.content" class="post-content" v-html="post.content"></view>
	</view>
</template>

<script setup>
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		ref
	} from 'vue';

	import {
		getPostsByIdApi
	} from '../../api/index.js'

	const post_id = ref('hello');
	const post = ref({});

	onLoad((e) => {
		post_id.value = e.post_id;
		uni.setNavigationBarTitle({
			title: e.title,
		});
		getPostsById();
	})

	async function getPostsById() {
		const res = await getPostsByIdApi(post_id.value);
		post.value = res.data;
	}
</script>

<style lang="scss" scoped>
	.post {
		view {
			border: solid 1px;
			padding: 10rpx;
			margin: 10rpx;
		}
	}
</style>